<template>
  <div class="right-bottom-wrap">
    <e-scatter :chartData="sdData" v-if="showSD" />
    <Spin fix v-show="sdLoading">加载中...</Spin>
  </div>
</template>
<script>
import { createNamespacedHelpers } from 'vuex'
import { merge, each } from 'lodash'
import { eScatterOptions } from './chartOptions'

const { mapActions, mapState } = createNamespacedHelpers('microGas')

// TODO：散点图模拟数据
const mnSdData1 = [
  [2.5376671395461, 4.18847047166445],
  [3.83388501459509, 1.74413298534789],
  [-0.258846861003648, 3.14155264212198],
  [2.86217332036812, 2.22991980210286],
  [2.31876523985898, 3.42924322425538],
  [0.692311703694727, 2.15101003397766],
  [1.56640797769432, 3.69291560229669],
  [2.34262446653865, 4.04561735691998],
  [5.57839693972576, 5.42097491995332],
  [4.76943702988488, 2.72546786295484],
  [0.650113059843479, -0.0240910232139351],
  [5.03492346633185, 1.81264220670072],
  [2.72540422494611, 4.91568567017784],
  [1.93694512681034, 1.48374345019695],
  [2.7147429038261, 4.35899399540202],
  [1.79503394170023, 3.17543290957418],
  [1.87585565178369, 5.03179584886474],
  [3.48969760778547, 0.226868626440577],
  [3.40903448980048, 2.72041248757026],
  [3.41719241342961, 1.29184853349448],
  [2.67149713360808, 7.11254439654734],
  [0.792513077314962, 4.16703575214446],
  [2.71723865132884, 4.95016087330213],
  [3.63023528916473, 1.50350712771881],
  [2.48889377031179, 2.33727748966815],
  [3.03469300991786, 2.6146700661066],
  [2.72688513338324, 4.55340699186258],
  [1.69655907521398, 2.6070297440489],
  [2.29387146709666, 3.99212944470151],
  [1.21271719624136, 0.0982935611674707],
  [2.88839563175764, 2.49958053410171],
  [0.85292989303085, 1.83527276633545],
  [0.931129541831968, 0.769704569721634],
  [1.19050130557512, 3.71838464065293],
  [-0.944284161994896, 3.39878568721598],
  [3.4383802928151, 3.04734770353676],
  [2.3251905394562, 1.11389456456612],
  [1.2450716808303, 4.59451487150162],
  [3.37029854009523, 3.49522847173902],
  [0.288483581146302, 2.57705676385801],
  [1.89775755391451, 3.03237105534926],
  [1.75855295839264, 2.62948250259111],
  [2.3192067391655, 0.524825931509414],
  [2.31285859663743, 2.59602852186483],
  [1.13512008267554, 1.82427020403826],
  [1.96994870380373, 1.61519316287115],
  [1.83512098079096, 1.36460109500927],
  [2.62770728752873, 2.24543629970475],
  [3.09326566903948, 0.167845381821152],
  [3.1092732976144, 4.36362632672483],
  [1.13634717801129, 3.73547604872744],
  [2.07735909113043, 2.97167634058193],
  [0.785882956384591, 2.95082625856008],
  [0.886499258513236, 1.87122623371707],
  [1.99315067189665, 4.44063854177609],
  [3.53263030828475, 2.811602033735],
  [1.23033408624632, 1.98950175164753],
  [2.37137881276006, 4.91114808170697],
  [1.77441559772875, 2.68212572410151],
  [3.11735613881447, 2.16698715612316],
  [0.910935704947764, 2.58456967808668],
  [2.03255746416497, 1.80085120635516],
  [2.55252702111222, 1.41589936478318],
  [3.10061021788087, 6.57230302314398],
  [3.54421189550395, 5.3412271483373],
  [2.08593113317543, 3.43492039310131],
  [0.508409689362391, 1.22216616669611],
  [1.25769816274014, 1.77604337338906],
  [0.938418266680014, 2.75034306143236],
  [4.35045722400204, 4.11923132783512],
  [1.38439811853311, 1.11626128223505],
  [2.74807678370399, -0.294929730267168],
  [1.80758148941174, 0.950666955269318],
  [2.88861042542072, 3.47165554332001],
  [1.23515076343213, 3.5534575750726],
  [0.597731030661241, 3.63877116009311],
  [0.577624074908504, 2.81574967655225],
  [2.48819390985994, 3.25977561062801],
  [1.82262484338117, 2.32661794613244],
  [1.80394651219267, 4.21908265412251],
  [3.41931015064255, 1.07427321148612],
  [2.29158437398418, 3.64350897000419],
  [2.19781105346436, 1.79974368438456],
  [3.58769908997406, 2.52639834905543],
  [1.19553404365045, 3.78175370488876],
  [2.69662441584961, 4.46949609472183],
  [2.83508816507268, 1.41942021629353],
  [1.75628485962205, 4.78284064396253],
  [2.21567008640374, 3.93358338317621],
  [0.834156068517951, 2.90402361376197],
  [0.852047221101406, 2.72391553426886],
  [2.10487471601649, 2.69225814836899],
  [2.722254032225, 2.57134109102572],
  [4.58549125261624, 3.03259143461534],
  [1.33310932929861, 3.07253551686028],
  [2.18733102457894, 4.168229201289],
  [1.91750557462904, 5.15947113980587],
  [0.0669770821490134, 3.66031672741308],
  [1.56103384606523, 2.70342055264011],
  [0.205321158544877, 3.8841526820582]
]
const mnSdData2 = [
  [7.18322726300144, 8.11304333719485],
  [5.97023245643338, 6.65864532938162],
  [7.94922183113102, 8.58193561760627],
  [7.3070619191467, 8.95739119422393],
  [7.13517494209946, 9.21301699831821],
  [7.51524633552485, 7.02255339112545],
  [7.26140632405538, 8.63551592930955],
  [6.05851422904457, 8.14231704884262],
  [6.83766232719617, 9.16823939530569],
  [6.85394536566847, 8.75824061399359],
  [6.46798862319118, 9.26980598952593],
  [8.68210359466318, 7.81341167779047],
  [6.12427065383998, 7.79182570430981],
  [6.51618494988988, 9.42520681758187],
  [6.28799545097258, 4.99669764324394],
  [5.82578766854318, 7.286407061933],
  [6.80776048246073, 6.20310809680461],
  [6.7259297700674, 7.45894338325301],
  [8.5300725144241, 8.91737101001933],
  [6.75097525748629, 9.16775453327737],
  [5.93578658711067, 6.5646529354774],
  [8.60345729812005, 7.33380654065756],
  [8.23467914689078, 8.19378243537718],
  [6.77037354903682, 7.5872428556493],
  [5.49384029602028, 8.42683589422597],
  [6.55537218355302, 8.56558776354076],
  [6.84405896427523, 6.68483575086124],
  [7.27606825393154, 7.74992423968484],
  [6.73883635422352, 4.98476290160333],
  [7.44342191290409, 9.61978606483807],
  [7.39189420943245, 7.11033131383845],
  [5.74932109317359, 6.29749903970357],
  [6.05203907766857, 7.64086798461092],
  [6.25889390605959, 5.97958822819549],
  [6.49218244972183, 7.9705028741676],
  [6.67942449339976, 7.20709995796198],
  [7.01246904136162, 11.0798441863756],
  [3.97082265859585, 9.61003319105385],
  [6.54298535912842, 4.46886924349015],
  [8.24244840639074, 8.62413053228969],
  [5.93329860101525, 6.02273445396047],
  [7.93372816267124, 7.63929750545906],
  [7.35032100135611, 8.23250247019673],
  [6.97099423629127, 9.05745560458832],
  [7.18245216750598, 7.61385330098981],
  [5.43494398584928, 10.2292250456162],
  [6.91546052018228, 7.31985215730527],
  [8.60394635060288, 8.46317208311892],
  [7.09834777464011, 8.9400760087637],
  [7.04137361348962, 8.12047486318574],
  [6.26583088730326, 9.24585537689623],
  [6.96918626998768, 8.45709240308124],
  [7.23234701262448, 6.89104983217914],
  [7.42638755740895, 5.44681652132283],
  [6.6271912582765, 10.6284473547785],
  [6.76354541624281, 7.14506534959255],
  [9.02369088660305, 8.14617272109484],
  [4.74164602950381, 8.7964383458478],
  [9.2294456804569, 8.16065041342608],
  [7.33756370061311, 6.72052391962658],
  [8.00006081958913, 7.33855169417692],
  [5.33583552501294, 7.82337894283302],
  [6.40996543579478, 10.0915631568719],
  [6.72193583623469, 6.7826227764886],
  [7.42271569122048, 9.10968878840495],
  [5.32979930214953, 8.43645903017738],
  [7.4716343264163, 7.66927195672381],
  [5.78715280032554, 6.50521480760445],
  [7.06619004842461, 7.59816400834204],
  [7.65235588866137, 7.8774014268201],
  [7.32705996717709, 5.92196155717717],
  [8.08263350423676, 8.27178673714357],
  [8.00607711081905, 6.83710169642223],
  [6.34909226340225, 7.86672368238135],
  [7.25705615743397, 8.47547746662826],
  [6.05562219359578, 6.72062596015725],
  [5.67821147860744, 7.59234394454259],
  [7.92482593349371, 8.49506349938656],
  [7.00004984907525, 5.40370310206377],
  [6.94508108539059, 9.46509117973254],
  [7.91112726565386, 11.4287058326199],
  [7.59458369740905, 9.35679721215242],
  [7.35020117387454, 7.55343096204009],
  [8.250251228305, 8.60616400699786],
  [7.92978945855772, 6.53489627581427],
  [7.23976325705858, 10.6557028025452],
  [6.30963889688877, 9.33035692540468],
  [6.34844635824972, 9.11347508026165],
  [8.19210187053127, 6.76132673980735],
  [5.38816961132219, 8.45247640511303],
  [6.97553806336408, 7.21045265056846],
  [5.0511528231011, 7.55957229256901],
  [8.02049801445265, 7.19388424519746],
  [7.86171630239342, 6.54939360939588],
  [7.00116208348351, 6.71483966629563],
  [6.92916278683952, 7.70316034347263],
  [4.51371607929672, 5.59744337153455],
  [7.58117232267592, 8.85927697486724],
  [4.8075650800341, 7.8334080616929],
  [4.6807196933567, 8.98876202611288]
]

export default {
  name: 'micro-gas-right-bottom',
  components: {
    EScatter: () => import('@/commons/charts/EScatter')
  },
  computed: {
    ...mapState(['sdLoading', 'sdList']),
    showSD() {
      return this.sdList && this.sdList.length > 0
    },
    sdData() {
      const _serList = []
      each(this.sdList, (item, index) => {
        const { x, y, meterId } = item
        _serList.push({
          name: meterId,
          value: [x, y]
        })
      })

      return merge({}, eScatterOptions, {
        series: [
          {
            data: mnSdData1
          }, {
            data: mnSdData2
          }
        ]
      })
    }
  },
  mounted() {
    this.loadSdData()
  },
  methods: {
    ...mapActions(['loadSdData'])
  }
}
</script>
<style lang="less" scoped>
.right-bottom-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}
</style>
